#pragma once

#include "Misc/EngineEditorMacros.h"
#include "Object/Object.h"
#include "Framework/Tickable.h"
#include "Math/Vec2.h"
#include "EditorToolTipWindowViewModel.m.h"

class RWidget;
class RFont;

//a tooltip window
RCLASS()
class REditorToolTipWindowViewModel  : public RObject , public ITickable
{
    ROBJECT

public:
    REditorToolTipWindowViewModel();

    virtual void Tick(float DeltaSeconds);

    bool IsVisible() const
    {
        return AroundWidget && ElapsedTime>=ShowDelay;
    }

    void Show(const TWidgetAttribute<CString>& InContent
        , TSharedObjectPtr<RWidget> InAroundWidget);


    void Hide()
    {
        AroundWidget = nullptr;
        ElapsedTime=0;
    }

    CString GetContent()
    {
        return Content.Get();
    }

    SVec2 GetToolTipPosition() const
    {
        return ToolTipPosition;
    }

    SVec2 GetToolTipSize() const
    {
        return TooltipSize;
    }

    TSharedObjectPtr<RFont> GetFont() const
    {
        return Font;
    }

    int64_t GetFontSize() const
    {
        return FontSize;
    }

protected:
    TWidgetAttribute<CString> Content;

    float ElapsedTime = 0;
    const float ShowDelay = 0.5f;
    TWeakObjectPtr<RWidget> AroundWidget;
    //SVec2 ScreenMousePosition;

    SVec2 TooltipSize;

    friend class REditorToolTipWindowView;

    SVec2 ToolTipPosition;

    TSharedObjectPtr<RFont> Font;
    int64_t FontSize = 16;
};